package com.heima.common.exception.config;

import com.heima.utils.common.SnowflakeIdWorker;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
public class IdWorkerConfig {
    @Value("${leadnews.worker-id}")
    private Long workerId;

    @Value("${leadnews.datacenter-id}")
    private Long datacenterId;

    @Bean
    private SnowflakeIdWorker snowFlake() {
        return new SnowflakeIdWorker(workerId, datacenterId);
    }
}
